package cn.com.cifi.mars.web.action.sys;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import cn.com.cifi.mars.bean.dto.ProjectByStagesDto;
import cn.com.cifi.mars.bean.vo.sys.rsp.CityVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.ProjectVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.RegionVo;
import cn.com.cifi.mars.bean.vo.sys.rsp.StagesVo;
import cn.com.cifi.mars.common.base.BaseAction;
import cn.com.cifi.mars.common.bean.R;
import cn.com.cifi.mars.entity.common.IdmUser;
import cn.com.cifi.mars.service.IdmUserService;
import cn.com.cifi.mars.service.OrgService;
@RestController
public class OrgController extends BaseAction implements IOrgController{
	
	@Autowired
	private OrgService orgService;
	@Autowired
	private IdmUserService idmUserService;
	
	/**
	 * 组织机构树形菜单
	 */
	@Override
	public R<String> getOrgTreeList(String apiVersion) {
        return ok(orgService.queryOrgTreeList());
	}


	/**
	 * 显示区域下拉框
	 */
	@Override
	public R<List<RegionVo>> getRegion(String apiVersion) {
		return ok(orgService.queryRegionList());
	}
	
	/**
	 * 项目下拉框
	 */
	@Override
	public R<List<ProjectVo>> getProject(String apiVersion,String regionId) {
		return ok(orgService.queryProject(regionId));
	}

	/**
	 * 项目分期下拉框
	 */
	@Override
	public R<List<StagesVo>> getStages(String apiVersion, String projectId) {
		return ok(orgService.queryStagesList(projectId));
	}

	
	/**
	 * 项目分期V1版本 带权限
	 */
	@Override
	public R<List<ProjectByStagesDto>> getStagessV1(String apiVersion) {
		IdmUser user = getOperator();
		List<ProjectByStagesDto> projectByStagesDtoList =null;
		if(null!=user) {
			projectByStagesDtoList = idmUserService.queryUserDataPermissions(user.getUsername());
		}
		return ok(projectByStagesDtoList);
	}

	/**
	 * 获取区域信息
	 */
	@Override
	public R<List<CityVo>> getCityList(String apiVersion, String regionId) {
		return ok(orgService.queryCityList(regionId));
	}
}
